{% extends "layout_with_sidebar.html" %}
{% load text_filters %}
{% load static %}
{% load paginator %}
{% load posts %}

{% block title %}
    {% if room %}{{ room.title }} — {% endif %}{{ block.super }}
{% endblock %}

{% block og_tags %}
    <meta property="og:title" content="{% if room %}{{ room.title }} — {% endif %}{{ settings.APP_NAME }}">
    <meta property="og:site_name" content="{{ settings.APP_NAME }}">
    <meta property="og:url" content="{{ settings.APP_HOST }}">
    <meta property="og:type" content="website" />
    <meta property="og:description" content="{% if room %}{{ room.description }}{% endif %}">
    <meta property="og:image" content="{% static "images/share.png" %}">

    <meta name="twitter:card" content="summary">
    <meta name="twitter:title" content="{% if room %}{{ room.title }} — {% endif %}{{ settings.APP_NAME }}">
    <meta name="twitter:description" content="{% if room %}{{ room.subtitle }}{% endif %}">
    <meta name="twitter:image" content="{% static "images/share.png" %}">
{% endblock %}

{% block feed_content %}
    {% if room %}
        {% include "rooms/widgets/feed_header.html" %}
    {% endif %}

    <div class="feed-ordering">
        <a href="{% feed_ordering_url room label_code post_type "activity" %}"
        class="feed-ordering-item {% if ordering == "activity" %}feed-ordering-item-is-active{% endif %}"
        >
            Фид
        </a>

        <a href="{% feed_ordering_url room label_code post_type "new" %}"
        class="feed-ordering-item {% if ordering == "new" %}feed-ordering-item-is-active{% endif %}"
        >
            Новое
        </a>

        <a href="{% feed_ordering_url room label_code post_type "hot" %}"
        class="feed-ordering-item {% if ordering == "hot" %}feed-ordering-item-is-active{% endif %}"
        >
            Обсуждаемое
        </a>

        {% if me and me.created_at < date_month_ago %}
            <a href="{% feed_ordering_url room label_code post_type "top_month" %}"
            class="feed-ordering-item {% if ordering == "top" or ordering == "top_week" or ordering == "top_month" or ordering == "top_year" %}feed-ordering-item-is-active{% endif %}"
            >
                Лучшее
            </a>
        {% else %}
            <a href="{% feed_ordering_url room label_code post_type "top_year" %}"
            class="feed-ordering-item {% if ordering == "top" or ordering == "top_week" or ordering == "top_month" or ordering == "top_year" %}feed-ordering-item-is-active{% endif %}"
            >
                Лучшее
            </a>
        {% endif %}

        {% if ordering == "top" or ordering == "top_week" or ordering == "top_month" or ordering == "top_year" %}
            <select class="feed-ordering-item" onchange="location.href = location.protocol + '//' + location.host + location.pathname + '../' + event.target.value + '/'">
                {% for option in feed_ordering_options %}
                    <option value="{{ option.value }}" {% if ordering == option.value %}selected{% endif %}>
                        {{ option.text }}
                    </option>
                {% endfor %}
            </select>
        {% endif %}
    </div>

    {% if ordering == "top_year" or ordering == "top_month" %}
        <div class="feed-ordering-extra">
            {% if ordering == "top_year" %}
                {% for option in feed_ordering_years %}
                    <a href="{% feed_ordering_url room label_code post_type option.value %}"
                       class="feed-ordering-extra-item {% if ordering_full == option.value %}feed-ordering-extra-item-selected{% endif %}">
                        {{ option.text }}
                    </a>
                {% endfor %}
            {% elif ordering == "top_month" %}
                {% for option in feed_ordering_months %}
                    <a href="{% feed_ordering_url room label_code post_type option.value %}"
                       class="feed-ordering-extra-item {% if ordering_full == option.value %}feed-ordering-extra-item-selected{% endif %}">
                        {{ option.text }}
                    </a>
                {% endfor %}
            {% endif %}
        </div>
    {% endif %}

    {% for post in pinned_posts %}
        {% include "posts/items/items.html" %}
    {% endfor %}

    {% if waiting_for_moderation_posts %}
        {% for post in waiting_for_moderation_posts %}
            {% include "posts/items/items.html" %}
        {% endfor %}
    {% endif %}

    {% for post in posts %}
        {% include "posts/items/items.html" %}
    {% endfor %}

    <div class="feed-paginator">
        {% paginator posts %}
    </div>
{% endblock %}
